<template>
	<view class="replay">
		<view class="dtail-header">
			<image v-if="userInfo.avatar" :src="userInfo.avatar" class="detail-img" mode=""></image>
			<view class="header-info">
				<view class="user-info">
					<view class="user_level">
						<text>{{ userInfo.nickname }}</text>
						<text class="level">LV{{ userInfo.userLevel || 0 }}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="replay_content" v-if="commentDetail.commentContent">
			回复<text>@{{ commentDetail.nickname}}</text>{{ commentDetail.commentContent }}
		</view>
		<view class="replay_input">
			<u-form ref="uForm" label-position="top">
				<u-form-item prop="name" class="form-item">
					<u-input type="textarea" v-model="commentContent" height="318" :autoHeight="true" placeholder-style="color: #BBBBBB;" placeholder="请填写文字简介，不超过200个字" maxlength="200" />
				</u-form-item>
			</u-form>
		</view>
		<view class="replay_tips">
			温馨提示：评论泡泡，金币-1，活力值+2
		</view>
		<view class="replay-btn">
			<button type="default" class="recharge_coin" @click="onGo">发送泡泡</button>
		</view>
	</view>
</template>

<script>
import { mapState } from 'vuex';
export default {
	props: ['bubbleId', 'commentDetail'],
	data() {
		return {
			commentContent: null,
			isClick: false,
		}
	},
	computed: {
		...mapState(["userInfo"])
	},
	mounted() {
		// console.log(this.bubbleId, this.commentDetail)
	},
	methods: {
		async onGo() {
			if(!this.commentContent) {
				wx.showToast({
					title: '请填写文字简介',
					icon: 'none',
					duration: 1000
				})
				return
			}
			if(this.isClick) return
			this.isClick = true
			uni.showLoading()
			await this.$u.post('/paopao/mini/space/createPaoPaoComment', {
				bubbleId: this.bubbleId,
				commentContent: this.commentContent,
				parentCommentId: this.commentDetail.id || 0
			}).then(res => {
				uni.hideLoading()
				wx.showToast({
					title: '发送泡泡成功',
					icon: 'none',
					duration: 1000
				})
				setTimeout(() => {
					this.isClick = false
					this.$emit('resetPapaComment')
					this.$emit('close')
				}, 1000)
			})
		}
	}
}
</script>

<style lang="less" scoped>
@import url("../../../common/css/var.less");
.replay {
	padding: 48rpx;
}
.dtail-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	color: @tText;
	.detail-img {
		width: 96rpx;
		height: 96rpx;
		border-radius: 50%;
		overflow: hidden;
		margin-right: 24rpx;
	}
}
.header-info {
	display: flex;
	align-items: flex-start;
	flex-basis: 82%;
	flex-direction: column;
	.user-time {
		padding-top: 8rpx;
		font-size: 24rpx;
		color: @tText;
	}
	.user-info {
		display: flex;
		align-items: flex-start;
		flex-direction: row;
		justify-content: space-between;
		width: 100%;
		font-size: 32rpx;
		color: @mText;
		
		.user_level {
			display: flex;
			align-items: center;
		}
		.level {
			margin-left: 16rpx;
			padding: 0 12rpx;
			height: 32rpx;
			line-height: 32rpx;
			background: #C165DD;
			border-radius: 16rpx;
			font-size: 24rpx;
			color: #FFFFFF;
		}
	}
}
.replay_content {
	color: @mText;
	font-size: 28rpx;
	padding-top: 32rpx;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	text {
		padding: 0 16rpx;
	}
}
.replay_input {
	background-color: #F7F7F7;
	border-radius: 16rpx;
	font-size: 28rpx;
	padding: 0 32rpx;
	margin-top: 32rpx;
}
.replay_tips {
	font-size: 24rpx;
	color: @tText;
	padding: 32rpx 0;
}
.replay-btn {
	padding-top: 12rpx;
	background-color: #FFFFFF;
	.recharge_coin {
		line-height: 96rpx;
		background: @mColor !important;
		box-shadow: 0 16rpx 48rpx rgba(0, 0, 0, 0.06);
		border-radius: 48rpx;
		color: @mText;
		font-size: 36rpx;
	}
}
</style>
